<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div>
        <div>
            <table>
                <tr>
                    <th>
                        账号：
                    </th>
                    <th>
                        <input type="text" name="username">
                    </th>
                </tr>
                <tr>
                    <th>
                        密码:
                    </th>
                    <th>
                        <input type="text" name="password">
                    </th>
                </tr>
                <tr>
                    <th>
                        <input type="button" value="保存" onclick="save()">
                    </th>
                    <th>
                        <input type="button" value="取消" onclick="cancel()">
                    </th>
                </tr>
            </table>
        </div>
    </div>  
    <script src="./jquery-3.6.0.min.js"></script>
    <script src="./baseurl.js"></script>
    <script src="./js.js"></script>
    <script>
        function save() {
            let use = $('[name=username]').val();
            let psw = $('[name=password]').val();
            let obj = {
                zhanghao: parseInt(use),
                password: psw
            }
            console.log(obj);
            if (use != '' || password || '') {
                getaddlogin(obj);
                location.href='./index.html'
            } else {
                alert('账号密码不能为空')
            }
        }
        function cancel(){
            location.href='./index.html'
        }
    </script>
</body>

</html>